package cn.ranko.shiro.service;

import cn.ranko.bean.Datagrid;
import cn.ranko.bean.Pagination;
import cn.ranko.shiro.mapper.SysPicklistMapper;
import cn.ranko.shiro.model.SysPicklist;
import cn.ranko.shiro.model.SysUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by user on 2017/9/4.
 */
@Service
public class SysPicklistService {

    @Autowired
    SysPicklistMapper sysPicklistMapper;

    public Datagrid loadList(Pagination pagination) {
        Integer total = sysPicklistMapper.countOfSysPicklist();
        List<SysPicklist> rows = sysPicklistMapper.querySysPicklist(pagination);
        Datagrid datagrid = new Datagrid();
        datagrid.setTotal(total);
        datagrid.setRows(rows);
        return datagrid;
    }

    public SysPicklist getByPicklistId(Integer picklist_id) {
        return sysPicklistMapper.selectByPrimaryKey(picklist_id);
    }

    public Integer updatePicklist(SysPicklist picklist) {
        return sysPicklistMapper.updateByPrimaryKeySelective(picklist);
    }

    public Integer insertPicklist(SysPicklist picklist) {
        return sysPicklistMapper.insertSelective(picklist);
    }

    public Integer removePicklist(Integer picklist_id) {
        SysPicklist picklist = new SysPicklist();
        picklist.setPicklistId(picklist_id);
        picklist.setDeleted(1);
        return sysPicklistMapper.updateByPrimaryKeySelective(picklist);
    }
}
